<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>新闻详情</title>
    <link rel="stylesheet" href="../lib/bootstrap.min.css">
    <link rel="stylesheet" href="../css/main.css">
    <script src="../lib/jquery-3.3.1.js"></script>
    <script src="../lib/bootstrap.js"></script>
</head>

<body>

    <div class="navbar-default" style="height:25px;">
        <div class="container">

        </div>
    </div>

    <div class="container" style="margin-left: 20%;">
        <div class="col-sm-2" id="sidebar">
            <div class="list-group side-bar hidden-xs" id="channel">
                <a href="#" class="list-group-item " id="findAll">综合</a>
                <a href="#" class="list-group-item" id="findLost">失物</a>
                <a href="#" class="list-group-item" id="findLoster">拾物</a>
                <a href="#" class="list-group-item active" id="noticeList">公告</a>
            </div>
        </div>
        <div class="col-md-7 text-center" id="noticeShow">

        </div>
        
    </div>

    <div class="footer">

    </div>
</body>
<script src="../lib/jquery-3.3.1.js"></script>
<script src="../js/application.js"></script>
<script src="../layui/layui.js"></script>
<script src="../lib/jquery.params.js"></script>
<script>
    $(function () {

        var $sidebar = $("#sidebar"),
            $window = $(window),
            offset = $sidebar.offset(),
            topPadding = 15;

        $window.scroll(function () {
            if ($window.scrollTop() > offset.top) {
                $sidebar.stop().animate({
                    marginTop: $window.scrollTop() - offset.top + topPadding
                });
            } else {
                $sidebar.stop().animate({
                    marginTop: 0
                });
            }
        });

        $("#channel a").on('click', function () {
            var id = $(this).attr("id");
            $(location).attr('href', 'index.html?type=' + id);
        })

        /**
         * 页面获取参数方法
         * @param name
         * @returns
         */
        var LocString = String(window.document.location.href);
        function GetQueryString(name) {
            var rs = new RegExp("(^|)" + name + "=([^&]*)(&|$)", "gi").exec(LocString), tmp;
            if (tmp = rs) {
                return decodeURI(tmp[2]);
            }
            // parameter cannot be found
            return "";
        }
        var noticeId = GetQueryString("noticeId");
        //    noticeId=
        layui.use(['layer'], function () {
            $ = layui.$
                , layer = layui.layer
            $.ajax({
                url: urlapi + 'notice/selectNotice',
                data: { id: noticeId },
                type: "Post",
                dataType: "json",
                success: function (data) {
                    $.each(data.data, function (index, item) {
                        $("#noticeShow").append(
                            ' <h1 class="news-title">' + item.title + '</h1>' +
                            '<div class="news-status">' + item.createdDate + '</div>' +
                            '<div class="news-content">' + item.content + '</div>'
                        );

                    });
                },
                error: function () {
                    layer.msg('公告查询失败');
                }
            });
        })

    })
</script>

</html>